/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package terminal.ui.forms;

import java.awt.event.KeyListener;
import javax.swing.AbstractButton;
import javax.swing.text.Document;

/**
 *
 * @author prpo4526
 */
public class FrameMain extends javax.swing.JFrame {

    /**
     * Creates new form FrameMain
     */
    public FrameMain() {
        initComponents();
    }

    public Document getTextAreaDocument()
    {
        return TextAreaLog.getDocument();
    }
    
    public void setTextAreaDocument( Document document )
    {
        TextAreaLog.setDocument( document );
    }
    
    public void addKeyListener( KeyListener keyListener )
    {
        TextAreaLog.setFocusable( true );
        TextAreaLog.addKeyListener( keyListener );
    }
    
    public void setStatusText( final String text )
    {
        LabelStatus.setText( text );
    }
    
    public AbstractButton getTriggerExit()
    {
        return MenuItemAppClose;
    }
    
    public AbstractButton getTriggerAbout()
    {
        return MenuItemAbout;
    }
    
    public AbstractButton getTriggerSettings()
    {
        return MenuItemSettings;
    }
    
    public AbstractButton getTriggerPortOpen()
    {
        return MenuItemPortOpen;
    }
    
    public AbstractButton getTriggerPortClose()
    {
        return MenuItemPortClose;
    }
    
    public AbstractButton getTriggerTerminal()
    {
        return MenuItemTerminal;
    }
    
    public AbstractButton getTriggerFilter()
    {
        return MenuItemNewFilter;
    }
    
    public AbstractButton getTriggerCloseAll()
    {
        return MenuItemCloseAll;
    }

    
    
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        PanelStatusBar = new javax.swing.JPanel();
        LabelStatus = new javax.swing.JLabel();
        SeparatorStatusBar = new javax.swing.JSeparator();
        jScrollPane2 = new javax.swing.JScrollPane();
        TextAreaLog = new javax.swing.JTextArea();
        DesktopPane = new javax.swing.JDesktopPane();
        MenuBarMain = new javax.swing.JMenuBar();
        MenuFile = new javax.swing.JMenu();
        MenuItemPortOpen = new javax.swing.JMenuItem();
        MenuItemPortClose = new javax.swing.JMenuItem();
        MenuItemAppClose = new javax.swing.JMenuItem();
        MenuPortConfiguration = new javax.swing.JMenu();
        MenuItemSettings = new javax.swing.JMenuItem();
        MenuWindow = new javax.swing.JMenu();
        MenuItemTerminal = new javax.swing.JMenuItem();
        MenuItemNewFilter = new javax.swing.JMenuItem();
        MenuItemCloseAll = new javax.swing.JMenuItem();
        MenuHelp = new javax.swing.JMenu();
        MenuItemAbout = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Serial Terminal");

        LabelStatus.setHorizontalAlignment(javax.swing.SwingConstants.TRAILING);
        LabelStatus.setText("LabelStatus");
        LabelStatus.setVerticalAlignment(javax.swing.SwingConstants.TOP);

        javax.swing.GroupLayout PanelStatusBarLayout = new javax.swing.GroupLayout(PanelStatusBar);
        PanelStatusBar.setLayout(PanelStatusBarLayout);
        PanelStatusBarLayout.setHorizontalGroup(
            PanelStatusBarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(SeparatorStatusBar)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, PanelStatusBarLayout.createSequentialGroup()
                .addContainerGap(295, Short.MAX_VALUE)
                .addComponent(LabelStatus, javax.swing.GroupLayout.PREFERRED_SIZE, 292, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        PanelStatusBarLayout.setVerticalGroup(
            PanelStatusBarLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(PanelStatusBarLayout.createSequentialGroup()
                .addComponent(SeparatorStatusBar, javax.swing.GroupLayout.PREFERRED_SIZE, 2, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(LabelStatus, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        TextAreaLog.setEditable(false);
        TextAreaLog.setColumns(20);
        TextAreaLog.setRows(5);
        jScrollPane2.setViewportView(TextAreaLog);

        DesktopPane.setBackground(new java.awt.Color(113, 111, 100));
        DesktopPane.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        DesktopPane.setAutoscrolls(true);

        MenuFile.setText("File");

        MenuItemPortOpen.setText("Open Port...");
        MenuFile.add(MenuItemPortOpen);

        MenuItemPortClose.setText("Close Port");
        MenuItemPortClose.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                MenuItemPortCloseActionPerformed(evt);
            }
        });
        MenuFile.add(MenuItemPortClose);

        MenuItemAppClose.setText("Exit");
        MenuFile.add(MenuItemAppClose);

        MenuBarMain.add(MenuFile);

        MenuPortConfiguration.setText("Configuration");

        MenuItemSettings.setLabel("Settings...");
        MenuPortConfiguration.add(MenuItemSettings);

        MenuBarMain.add(MenuPortConfiguration);

        MenuWindow.setText("Window");

        MenuItemTerminal.setText("Open Terminal...");
        MenuWindow.add(MenuItemTerminal);

        MenuItemNewFilter.setText("Open New Filter...");
        MenuWindow.add(MenuItemNewFilter);

        MenuItemCloseAll.setText("Close");
        MenuWindow.add(MenuItemCloseAll);

        MenuBarMain.add(MenuWindow);

        MenuHelp.setLabel("?");

        MenuItemAbout.setLabel("About...");
        MenuHelp.add(MenuItemAbout);

        MenuBarMain.add(MenuHelp);

        setJMenuBar(MenuBarMain);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(PanelStatusBar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addComponent(DesktopPane, javax.swing.GroupLayout.PREFERRED_SIZE, 267, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 357, Short.MAX_VALUE)
                    .addComponent(DesktopPane))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(PanelStatusBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void MenuItemPortCloseActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_MenuItemPortCloseActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_MenuItemPortCloseActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Motif".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(FrameMain.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(FrameMain.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(FrameMain.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(FrameMain.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new FrameMain().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JDesktopPane DesktopPane;
    private javax.swing.JLabel LabelStatus;
    private javax.swing.JMenuBar MenuBarMain;
    private javax.swing.JMenu MenuFile;
    private javax.swing.JMenu MenuHelp;
    private javax.swing.JMenuItem MenuItemAbout;
    private javax.swing.JMenuItem MenuItemAppClose;
    private javax.swing.JMenuItem MenuItemCloseAll;
    private javax.swing.JMenuItem MenuItemNewFilter;
    private javax.swing.JMenuItem MenuItemPortClose;
    private javax.swing.JMenuItem MenuItemPortOpen;
    private javax.swing.JMenuItem MenuItemSettings;
    private javax.swing.JMenuItem MenuItemTerminal;
    private javax.swing.JMenu MenuPortConfiguration;
    private javax.swing.JMenu MenuWindow;
    private javax.swing.JPanel PanelStatusBar;
    private javax.swing.JSeparator SeparatorStatusBar;
    private javax.swing.JTextArea TextAreaLog;
    private javax.swing.JScrollPane jScrollPane2;
    // End of variables declaration//GEN-END:variables
}
